﻿<cfmodule template="../../tag/layout.cfm" bodyIsEasyUILayout="false">
<form method="post" class="form">
  <fieldset>
    <legend>基本信息</legend>
    <table class="table" width="100%">
      <tbody>
        <tr>
          <th>编号</th>
          <td><input name="id" readonly /></td>
          <th>供应商名称</th>
          <td><input name="supchsname" class="easyui-validatebox" data-options="required:true" style="width:300px;"/></td>
        </tr>
        <tr>
          <th>供应商编码</th>
          <td><input name="supcode" class="easyui-validatebox" data-options="required:true"/></td>
          <th>英文名称<br/>自动转换</th>
          <td><input name="supenname" style="width:300px;"/></td>
        </tr>

        <tr>
          <th>GMP(GSP)认证号</th>
          <td><input name="gmporgspno" class="easyui-validatebox" data-options="required:true"/></td>
          <th>GMP(GSP)认证图</th>
          <td>
          	<input name="gmporgsppic" id="gmporgsppic" readonly="readonly" />(证书图片，<a href="#" onclick="viewImg()">点击查看</a>)
          	<select class="selectFiles"><option>选择文件</option></select>
	      	<a href="#" class="easyui-linkbutton uploader" data-options="iconCls:'icon-add'">选择文件</a>
	      	<input name="gmporgsppicid" id="gmporgsppicid" class="selectFilesValue" type="hidden"/>
          </td>
        </tr>

		<tr>
          <th>有效期<br/>开始时间</th>
          <td><input name="startdate" class="easyui-datebox" data-options="required:true"/></td>
          <th>有效期<br/>结束时间</th>
          <td><input name="enddate" class="easyui-datebox" data-options="required:true"/></td>
        </tr>

        <tr>
          <th>拼音全码<br/>自动转换</th>
          <td><input name="suppyfullspell"/></td>
          <th>拼音简码<br/>自动转换</th>
          <td><input name="suppysimplespell" /></td>
        </tr>

        <tr>
          <th>企业法人<br/>营业执照<br/>注册号</th>
          <td><input name="buslicense"/></td>
          <th>许可证类型</th>
          <td><input name="licencetype" /></td>
        </tr>


        <tr>
          <th>法定代表人</th>
          <td><input name="corporation"/></td>
          <th>企业负责人</th>
          <td><input name="companyprincipal" /></td>
        </tr>

        <tr>
          <th>质量负责人</th>
          <td><input name="qualityprincipal"/></td>
          <th>联系电话</th>
          <td><input name="phone" /></td>
        </tr>

        <tr>
          <th>仓库地址</th>
          <td colspan="3"><input name="storageaddress" style="width:510px;"/></td>
        </tr>

        <tr>
          <th>公司地址</th>
          <td colspan="3"><input name="suppleaddress" style="width:510px;"/></td>
        </tr>

		<tr>
          <th>生产经营<br/>范围</th>
          <td colspan="3"><input name="scope" style="width:510px;"/></td>
        </tr>

        <tr>
          <th>认证范围</th>
          <td colspan="3"><input name="approvescope" style="width:510px;"/></td>
        </tr>

		<tr>
          <th>联系代理人</th>
          <td><input name="contactagent" /></td>
          <th>生产(经营)<br/>许可证号</th>
          <td><input name="lesence" /></td>
        </tr>

        <tr>
          <th>采购员</th>
          <td><input name="bailer" /></td>
          <th>引进原因</th>
          <td><input name="importcause"  style="width:300px;"/></td>
        </tr>

		<tr>
          <th>备注</th>
          <td colspan="3"><input name="content" style="width:578px;"/></td>
        </tr>

      </tbody>
    </table>
  </fieldset>
</form>

</cfmodule>
<cfscript>
	if( structKeyExists(rc, "id")  && rc.id > 0 ){
		id = rc.id;
	}else{
		id = 0;
	}
</cfscript>

<script type="text/javascript">
	function viewImg(){
		if( $('#gmporgsppic').val().trim().length > 0){
			window.open($('#gmporgsppic').val(),'_blank');
		}
	}

	var closeDialog = function($dialog) {
		$dialog.dialog('destroy');
	}

	var submitNow = function($dialog, $grid, $pjq) {
		var url;
		if ($(':input[name="id"]').val().length > 0) {
			url = '?action=supplier.update'; //更新操作
		} else {
			url = '?action=supplier.save';	//新增操作
		}
		$.post(url, fw.serializeObject($('form')), function(result) {
			if (result) {
				$grid.datagrid('reload');
				$dialog.dialog('destroy');
			}
		}, 'json');
	};

	var submitForm = function($dialog, $grid, $pjq) {
		if ($('form').form('validate')) {
			submitNow($dialog, $grid, $pjq);
		}
	};

	//加载数据，初始进度条
	parent.$.messager.progress({
		text : '数据加载中....'
	});

	$(function(){
		$(".uploader").on('click',uploaderFun);

		$.ajax({
		    type: "POST",
		    url: "?action=supplier.get",
		    data: {
		        id:<cfoutput>#id#</cfoutput>
		    }
		}).done(function(result) {
			$('form').form('load', result);
			parent.$.messager.progress('close');
		}, 'json');
	})
</script>
